package com.fantastic.web.controller.app;

import com.fantastic.common.exception.enums.RespStatusInfo;
import com.fantastic.common.result.ResultData;
import com.fantastic.model.pojo.zjs.Orders;
import com.fantastic.service.lwf.OrdersInfoService;
import com.fantastic.service.zjs.OrdersService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author .FengYe.
 * @date 2024-06-11
 * 我的订单 请求控制器
 */
@RestController
@RequestMapping("/app")
public class OrdersController {

    @Resource
    private OrdersInfoService ordersInfoService;

    @Resource
    private OrdersService ordersService;

    /**
     * 渲染前端 我的订单页面
     *
     * @param aId 用户id
     * @return json
     */
    @GetMapping("listMyOrdersAllApp")
    public ResultData listMyOrdersAllApp(@RequestParam("aId") int aId, @RequestParam(name = "way", defaultValue = "2") int way) {
        return new ResultData(RespStatusInfo.OK, ordersInfoService.queryOrders(aId, way));
    }

    /**
     * 查询单个账号下的所有订单信息
     *
     * @param orders
     * @return
     */
    @GetMapping("/listOrdersApp")
    public ResultData listOrdersApp(Orders orders) {
        return new ResultData(RespStatusInfo.OK, ordersService.listOrders(orders));
    }


    /**
     * 添加订单信息
     *
     * @param orders
     * @param couponsId 优惠卷id
     * @return
     */
    @PostMapping("/insertOrdersApp")
    public ResultData insertOrdersApp(Orders orders, Integer couponsId) {
        return new ResultData(RespStatusInfo.OK, ordersService.insertOrders(orders, couponsId));
    }


    /**
     * 删除订单信息
     *
     * @param orderId
     * @return
     */
    @PostMapping("/deleteOrdersApp")
    public ResultData deleteOrdersApp(Integer orderId) {
        return new ResultData(RespStatusInfo.OK, ordersService.deleteOrders(orderId));
    }


}
